<?php

namespace App\Providers;

use Phalcon\Cache\Backend\Redis;
use Phalcon\Cache\Frontend\Data as FrontData;
/**
 * \App\Providers\Redis
 *
 * @package App\Providers
 */
class ModelsCacheServiceProvider extends AbstractServiceProvider
{
    /**
     * The Service name.
     * @var string
     */
    protected $serviceName = 'modelsCache';

    /**
     * Register application service.
     *
     * @return void
     */
    public function register()
    {
        $this->di->setShared(
			$this->serviceName, 
			function () {
				$frontCache = new FrontData(
					  [
						  "lifetime" => 172800,
					  ]
				 );
				 $cache = new Redis($frontCache, [
					  "host"       => "localhost",
					  "port"       => 6379,
					  //"auth"       => "foobared",
					  "persistent" => false,
					  "index"      => 0,
				 ]);
				 return $cache;
			}
		);
    }
}
